/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package cn.cheln.explorer.cpnt.adapter;

import android.content.Context;
import android.view.View;
import android.widget.TextView;
import cn.cheln.explorer.beans.FileInfo;
import cn.cheln.support.ui.DensityUtil;
import cn.power.shine.R;

/**
 *
 * @author Administrator
 */
public abstract class FileAdapter extends ThumbnailAdapter {
    
    int fileNameMaxWidth;

    public FileAdapter(Context context, AdaptInfo listViewHolder) {
        super(context, listViewHolder);
    }
    int density180 = DensityUtil.dip2px(context, 180);
    int density260 = DensityUtil.dip2px(context, 260);
    @Override
    protected void getViewInDetail(Object item, int position, View convertView) {
        super.getViewInDetail(item, position, convertView);
        if(item==null){
            return;
        }
        ((TextView) convertView.findViewById(R.id.fileNameSubFileNum)).setMaxWidth(((FileInfo) item).getIsDir() ?  density180: density260);
    }
    
    public abstract FileInfo getSimpleFileItem(int pos);
    
    public int getPathOnlyItemPos(FileInfo info) {
        
        for (int i = 0; i < this.getCount(); i++) {
            if (info.getPath().equals(this.getSimpleFileItem(i).getPath())) {
                return i;
            }
        }
        return -1;
    }
}
